package cn.csc.module.search.service.sku;

import cn.csc.module.search.dal.dataobject.sku.SkuDO;
import cn.csc.module.search.dal.es.sku.SkuRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.List;
import java.util.Optional;

/**
 * @author liuchuang
 * @version 1.0
 * @modify
 * @since 2025/3/17 16:16
 */
@Service
public class SkuService {

    @Autowired
    private SkuRepository skuRepository;

    public Page<SkuDO> searchSpuByName(String name, int page, int size) {
        return skuRepository.findBySkuName(name, PageRequest.of(page, size));
    }

    /**
     * 根据ID查询
      */
    public Optional<SkuDO> findById(BigInteger id) {
        return skuRepository.findById(id);
    }

    /**
     * 根据spu_id查询
     */
    public List<SkuDO> findBySpuId(BigInteger spuId) {
        return skuRepository.findBySpuId(spuId);
    }


}
